package com.yigo.framework.http;

import org.springframework.util.ObjectUtils;

/**
 * 业务异常
 *
 * @author chenzl
 */
public class BException extends RuntimeException implements ErrorCode {
    private ErrorCode errorCode;
    private Object[] args;

    public BException(ErrorCode errorCode, Object... args) {
        this.errorCode = errorCode;
        this.args = args;
    }

    @Override
    public String getCode() {
        return errorCode.getCode();
    }

    @Override
    public String getMsg(Object... args) {
        return errorCode.getMsg(ObjectUtils.isEmpty(args) ? this.args : args);
    }
}
